home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Publishing / ImagePortfolio / Source / FileUtils.h < prev    next >
Text File  |  1994-04-01  |  4KB  |  69 lines

  1. // -------------------------------------------------------------------------------------
  2. // FileName: file name utilities
  3. // The FileName class provides a set of utilities for manipulating file names.
  4. // -------------------------------------------------------------------------------------
  5. #import <objc/Object.h>
  6.  
  7. // -------------------------------------------------------------------------------------
  8. // filename macros
  9. #define    FILEUTILS                FileUtils
  10. #define    fileNAME(F)                [FILEUTILS copyFileName:F]
  11. #define    fileNAMEXT(F)            [FILEUTILS extractFileNameExt:F]
  12. #define    fileEXT(F)                [FILEUTILS extractFileExt:F]
  13. #define    filePATH(F)                [FILEUTILS copyFilePath:F]
  14. #define    sendDIRECTORY(D,T,M,A)    [FILEUTILS sendFileDirectory:D toTarget:T method:M with:A]
  15.  
  16. // -------------------------------------------------------------------------------------
  17. @interface FileUtils : Object
  18. {
  19.     // this object is not intended to be instantiated
  20. }
  21.   
  22. int methodNumberOfArgs(Object *obj, SEL aSelector);
  23.  
  24. // -------------------------------------------------------------------------------------
  25. + sendFileDirectory:(const char*)dirPath toTarget:target method:(SEL)method with:anArg;
  26. //  Sends all file names found in the specified directory to the specified target/method,
  27. //  one at a time.  aMethod must be a selector which accepts two arguments: the first of
  28. //  type (char*), into which will be passed a fully qualified file name found in the
  29. //  specified directory, and the second od type (id) into which will be passed anArg.
  30. //  Returns self if successful, otherwise returns (id)nil.
  31. //  Macros:    sendDIRECTORY(dirPath,theTarget,aMethod,anArg)
  32. //
  33. // -------------------------------------------------------------------------------------
  34. + (const char*)extractFileNameExt:(const char*)fileName;
  35. //  Returns a pointer to the start of the actual file name in fileName.  This is the
  36. //  first character following the last '/' found in the null-terminated string.
  37. //  Returns fileName if no '/' found.
  38. //  Macros:    fileNAMEXT(fileName)
  39. //  See also: +extractFileExt:, +copyFileName:, +copyFilePath:
  40. //
  41. // -------------------------------------------------------------------------------------
  42. + (const char*)extractFileExt:(const char*)fileName;
  43. //  Returns a pointer to the start of the file name extension in fileName.  This is the
  44. //  string starting with the last '.' found in the null-terminated string.  Returns an
  45. //  empty string if no '.' found.
  46. //  Macros:    fileEXT(fileName)
  47. //  See also: +extractFileNameExt:, +copyFileName:, +copyFilePath:
  48. //
  49. // -------------------------------------------------------------------------------------
  50. + (char*)copyFileName:(const char*)fileName;
  51. //  Returns a pointer to a copy of the file name in fileName.  This is the string of
  52. //  characters following the last '/' up to, but not including, the last '.'.  This
  53. //  method uses malloc() the create a copy of the string, so free() must be used to free
  54. //  storage used by the string.
  55. //  Macros:    fileNAME(fileName)
  56. //  See also: +copyFilePath:, +extractFileNameExt:, +extractFileExt:
  57. //
  58. // -------------------------------------------------------------------------------------
  59. + (char*)copyFilePath:(const char*)fileName;
  60. //  Returns a pointer to a copy of the file path in fileName.  This is the string of
  61. //  characters starting with the first character in the file path name up to, but not
  62. //  including, the last '/'.  This method uses malloc() the create a copy of the string,
  63. //  so free() must be used to free storage used by the string.
  64. //  Macros:    filePATH(fileName)
  65. //  See also: +copyFileName:, +extractFileNameExt:, +extractFileExt:
  66. //
  67. // -------------------------------------------------------------------------------------
  68.  
  69. @end